<?php
namespace Home\Controller;
use Think\Controller;

class TorrentController extends BaseController {
	public function index(){
		$hash = I('get.hash');

		// More Lik This
		// mlt=true&mlt.fl=file&mlt.count=5

		$model = D("Hash");
		$map['hash'] = $hash;
		$query_begin = microtime(true);
		$info = $model->where($map)->cache(true,3600)->find();
		$query_cost = microtime(true) - $query_begin;
		cookie("QueryCostTime", $query_cost);

		$this->assign("cost", number_format($query_cost*1000, 3) );
		$this->assign("info", $info);

		$magnet = "magnet:?xt=urn:btih:{$info['hash']}&dn=[www.CodEiT.cn]{$info['title']}";
		$down = zhuanhuan($magnet);
		$this->assign("magnet", $magnet);
		$this->assign("down", $down);

		$this->display();
	}

	public function qrcode(){
		$hash = I('get.hash');

		// More Lik This
		// mlt=true&mlt.fl=file&mlt.count=5

		$model = D("Hash");
		$map['hash'] = $hash;
		$query_begin = microtime(true);
		$info = $model->where($map)->cache(true,3600)->find();
		$query_cost = microtime(true) - $query_begin;
		cookie("QueryCostTime", $query_cost);

		$this->assign("cost", number_format($query_cost*1000, 3) );
		$this->assign("info", $info);

		$magnet = "magnet:?xt=urn:btih:{$info['hash']}&dn=[www.CodEiT.cn]{$info['title']}";
		$down = zhuanhuan($magnet);
		$this->assign("magnet", $magnet);
		$this->assign("down", $down);

		$this->display();
	}
}